import logging
from redis import StrictRedis


class  Config(object):
    DEBUG = True

    SECRET_KEY = "iECgbYWReMNxkRprrzMo5KAQYnb2UeZ3bwvReTSt+VSESW0OB8zbglT+6rEcDW9X"

    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1/information27"
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    # 在请求结束时候，如果指定此配置为 True ，那么 SQLAlchemy 会自动执行一次 db.session.commit()操作
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True

    REDIS_HOST = "127.0.0.1"
    REDIS_PORT = 6379

    SESSION_TYPE = "redis"
    SESSION_USE_SIGNER = True
    SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT)

    SESSION_PERMANENT = False
    PERMANENT_SESSION_LIFETIME = 86400 * 2

    LOG_LEVEL = logging.DEBUG

class DevelopmentConfig(Config):
    """开发环境下"""
    DEBUG = True

class ProductionConfig(Config):
    """生产环境下的"""
    DEBUG = False
    LOG_LEVEL = logging.WARNING
class TestingConfig(Config):
    """测试环境下"""
    DEBUG = True
    TESTING = True
config = {
    "development" : DevelopmentConfig,
    "production" : ProductionConfig,
    "testing" : TestingConfig
}